<?php
/**
 * Generates options for a <select> element representing all available data types
 *
 * @package Concerto
 * @subpackage Data Types
 */
function dataTypeSelect() {
	if ($handle = opendir(CN_APPLICATION_PATH . 'application/datatypes/')) {
		$files = array();
	    /* This is the correct way to loop over the directory. */
	    while (false !== ($file = readdir($handle))) {
	    	if(!is_dir($file) && substr($file, 0, 1) != '.' && !in_array($file, array('DataType.php', 'ID.php', 'Level.php', 'Status.php', 'Timestamp.php', 'Author.php', 'Permalink.php', 'FileUploadBase.php'))) {
	    		$files[] = str_replace('.php', '', $file);
			}
	    }
	    closedir($handle);
	    $files = array_merge($files, Modulator()->getDataTypeNames());
	    
	    // Order by name
	   	asort($files);
	    foreach($files as $file) {
	    	echo '<option value="'.$file.'">'.\application\utilities\Utility::camelCaseToNormal($file).'</option>';
	    }
	}
}

?>